package br.com.almanach.dominio.cadastro;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table
public class Evento implements Serializable {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column
    private Integer id;

    @Column
    private String nome;

    @Column
    @Temporal(TemporalType.DATE)
    private Date data;

    @OneToMany(mappedBy = "evento")
    private List<Levita> levitas;

    @OneToMany(mappedBy = "evento", fetch=FetchType.EAGER)
    private List<Ministracao> ministracoes;

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public List<Levita> getLevitas() {
        return levitas;
    }

    public void setLevitas(List<Levita> levitas) {
        this.levitas = levitas;
    }

    public List<Ministracao> getMinistracoes() {
        return ministracoes;
    }

    public void setMinistracoes(List<Ministracao> ministracoes) {
        this.ministracoes = ministracoes;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Evento other = (Evento) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if ((this.nome == null) ? (other.nome != null) : !this.nome.equals(other.nome)) {
            return false;
        }
        if (this.data != other.data && (this.data == null || !this.data.equals(other.data))) {
            return false;
        }
        if (this.levitas != other.levitas && (this.levitas == null || !this.levitas.equals(other.levitas))) {
            return false;
        }
        if (this.ministracoes != other.ministracoes && (this.ministracoes == null || !this.ministracoes.equals(other.ministracoes))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 37 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 37 * hash + (this.nome != null ? this.nome.hashCode() : 0);
        hash = 37 * hash + (this.data != null ? this.data.hashCode() : 0);
        hash = 37 * hash + (this.levitas != null ? this.levitas.hashCode() : 0);
        hash = 37 * hash + (this.ministracoes != null ? this.ministracoes.hashCode() : 0);
        return hash;
    }
    
}